#include<iostream>
#include<queue>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 50;
int mp[5][5];
PII pre[N];
bool st[N][N];
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
queue<PII>q;
int cnt;
void bfs()
{
	q.push({ 0,0 });
	bool flag = 0;
	while (q.size()) {
		PII t = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int a = dx[i] + t.x;
			int b = dy[i] + t.y;
			if (a == 4 && b == 4) {
				flag = 1;
				break;
			}
			if (a >= 5 || b >= 5 || mp[a][b] || st[a][b] || a < 0 || b < 0) {
				continue;
			}
			st[a][b] = 1;
			pre[cnt++] = { t.x,t.y };
			q.push({ a,b });
		}
		if (flag) {
			break;
		}
	}
}
int main()
{
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			cin >> mp[i][j];
		}
	}
	bfs();
	int a = pre[0].x;
	int b = pre[0].y;
	for (int i = 1; i <= cnt; i++) {
		printf("(%d, %d)\n", a, b);
		a = pre[i].x;
		b = pre[i].y;
	}
	cout << "(4, 4)" << endl;
	return 0;
}